/* GUI CONVERTED from rcctwb.p (converter v1.76) Mon Aug 27 09:54:35 2001 */
/* rcctwb.p - Container Workbench                                             */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.7.1.4 $                                                        */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.5    LAST MODIFIED: 03/21/95           BY: GWM *J049*          */
/* REVISION: 8.5    LAST MODIFIED: 06/11/96           BY: rxm *G1XQ*          */
/* REVISION: 8.5    LAST MODIFIED: 07/08/96           BY: jpm *J0X0*          */
/* REVISION: 8.6    LAST MODIFIED: 10/12/96   BY: *K003*  Vinay Nayak-Sujir   */
/* REVISION: 8.6    LAST MODIFIED: 01/28/97   BY: *K059*  Kieu Nguyen         */
/* REVISION: 8.6    LAST MODIFIED: 04/02/97   BY: *K09H*  Vinay Nayak-Sujir   */
/* REVISION: 8.6E   LAST MODIFIED: 02/23/98   BY: *L007*  A. Rahane           */
/* REVISION: 8.6E   LAST MODIFIED: 05/20/98   BY: *K1Q4*  Alfred Tan          */
/* REVISION: 8.6E   LAST MODIFIED: 10/04/98   BY: *J314*  Alfred Tan          */
/* REVISION: 9.1    LAST MODIFIED: 03/24/00   BY: *N08T*  Annasaheb Rahane    */
/* REVISION: 9.1    LAST MODIFIED: 09/05/00   BY: *N0RF*  Mark Brown          */
/* Revision: 1.7.1.3     BY: Jean Miller    DATE: 03/22/01 ECO: *P008*        */
/* $Revision: 1.7.1.4 $    BY: Kirti Desai    DATE: 05/22/01 ECO: *N0Y4*          */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rcctwb_p_1 "Site"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcctwb_p_2 "Container"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

/* SHARED VARIABLES */
define shared variable global_recid as recid.

/* LOCAL VARIABLES */
define variable disp_abs_id  like abs_id no-undo.
define variable num_recs     as   integer no-undo.
define variable ship_from    as   character no-undo.
define variable tmp_prefix   as   character no-undo.
define variable shipto_save  as   character no-undo.
define variable abs_recid    as   recid no-undo.
define variable return_code  as   integer no-undo.
define variable par_absid    like abs_id no-undo.
define variable par_shipfrom like abs_shipfrom no-undo.
define variable authorized   like mfc_logical no-undo.
define variable shipgrp      like sg_grp no-undo.

/* BUFFERS */
define buffer abs_temp for abs_mstr.

/* Define Temp Table work_abs_mstr */
{rcinvtbl.i new}

{sotmpdef.i new}


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
abs_shipfrom         colon 33 label {&rcctwb_p_1}
   si_desc              at 45    no-label
   abs_id               colon 33 label {&rcctwb_p_2} format "x(8)"
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

assign
   tmp_prefix = mfguser + "::".

/* CHECK IF EXISTING RECORD WITH GLOBAL_RECID */
find abs_mstr where recid(abs_mstr) = global_recid no-lock no-error.

if available abs_mstr and
   abs_id begins "C" and
   abs_type = "S"
then do:

   find si_mstr where si_site = abs_shipfrom no-lock.

   display
      abs_shipfrom
      si_desc
      substring(abs_id,2,8) @ abs_id
   with frame a.

end.

for each t_all_data exclusive-lock:
   delete t_all_data.
end. /* FOR EACH t_all_data */

/* MAKE SURE CONTROL FILE FIELDS EXIST */
{gprun.i ""rcpma.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


mainloop:
repeat with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.


   /* INPUT SHIPFROM AND CONTAINER ID */
   prompt-for
      abs_shipfrom
      abs_id
   editing:

      global_site = input abs_shipfrom.

      if frame-field = "abs_shipfrom" then do:
         {mfnp05.i abs_mstr abs_id
            "abs_id begins 'C' "
            abs_shipfrom
            "input abs_shipfrom"}
         if recno <> ? then do:
            find si_mstr where si_site = abs_shipfrom
            no-lock no-error.

            assign
               disp_abs_id = substring(abs_id,2,8).

            display
               abs_shipfrom
               si_desc when (available si_mstr)
               ""      when (not available si_mstr) @ si_desc
               disp_abs_id @ abs_id.
         end.
      end.
      else
         if frame-field = "abs_id" then do:
         {mfnp05.i abs_mstr abs_id
            "(abs_shipfrom = input abs_shipfrom
          and abs_id begins 'C' )"
            abs_id
            "('C' + input abs_id)"}
         .
         if recno <> ? then do:
            find si_mstr where si_site = abs_shipfrom
            no-lock no-error.

            assign
               disp_abs_id = substring(abs_id,2,8).

            display
               abs_shipfrom
               si_desc when (available si_mstr)
               ""      when (not available si_mstr) @ si_desc
               disp_abs_id @ abs_id.
         end.
      end.
      else do:
         status input.
         readkey.
         apply lastkey.
      end.
   end. /* PROMPT FOR EDITING */

   find si_mstr where si_site = input abs_shipfrom no-lock no-error.

   if not available si_mstr then do:
      /* Site does not exist */
      {pxmsg.i &MSGNUM=708 &ERRORLEVEL=3}
      next-prompt abs_shipfrom.
      undo mainloop, retry mainloop.
   end.
   else ship_from = si_site.

   /* Check Site Security */
   {gprun.i ""gpsiver.p""
      "(input si_site, input recno, output return_int)"}
/*GUI*/ if global-beam-me-up then undo, leave.


   if return_int = 0 then do:
      /* User does not have access to this site */
      {pxmsg.i &MSGNUM=725 &ERRORLEVEL=3}
      next-prompt abs_shipfrom.
      undo mainloop, retry mainloop.
   end.

   display
      si_desc.

   global_site = si_site.

   hide frame a no-pause.

   find abs_mstr where
        abs_shipfrom = ship_from and
        abs_id = "C" + input abs_id
   no-lock no-error.

   if available abs_mstr and
      abs_type <> "s"
   then do:
      {pxmsg.i &MSGNUM=5813 &ERRORLEVEL=3}
      /* SELECTED CONTAINER HAS INVALID TYPE */
      next-prompt abs_id with frame a.
      undo mainloop, retry mainloop.
   end.

   if available abs_mstr then
      abs_recid = recid(abs_mstr).
   else
      abs_recid = -1.

   if available abs_mstr then do:

      run get_abs_parent
         (input abs_mstr.abs_id,
          input abs_mstr.abs_shipfrom,
          output par_absid,
          output par_shipfrom).

      if abs_mstr.abs_id <> par_absid and
         par_absid <> ?
      then do for abs_temp:

         find abs_temp where
              abs_temp.abs_id = par_absid and
              abs_temp.abs_shipfrom = par_shipfrom
         no-lock no-error.

         if available abs_temp and abs_temp.abs_inv_mov <> ""
         then do:

            /* Validate Site-Inventory Movement Code Combination */
            {gprun.i ""gpsimver.p""
               "(input abs_temp.abs_shipfrom,
                 input abs_temp.abs_inv_mov,
                 output authorized)"}
/*GUI*/ if global-beam-me-up then undo, leave.

            if not authorized then do:
               /* No access to Site/Inv Mvmt Code of Parent Shipper # */
               {pxmsg.i &MSGNUM=5991 &ERRORLEVEL=4
                        &MSGARG1=substring(abs_temp.abs_id,2)}
                  undo mainloop, retry mainloop.
            end.

         end. /* if available abs_temp and ... */

      end. /* if abs_mstr_id <> par_absid and .. */

   end. /* if available abs_mstr  */

   /* CLEAN UP ANY OLD RECORDS IF FOUND */
   for each abs_temp where
            abs_temp.abs_shipfrom = ship_from
        and abs_temp.abs_shipto begins tmp_prefix:
      abs_temp.abs_shipto = abs_temp.abs__qad05.
   end.

   /* CONTAINER WORKBENCH */
   {gprun.i ""rcctwbb.p""
      "(input ship_from,
        input tmp_prefix,
        input abs_recid)"}
/*GUI*/ if global-beam-me-up then undo, leave.


   global_recid = recid(abs_mstr).

end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* mainloop */

/* Internal procedure get_abs_parent included in this .i */
{rcinvcon.i}
